package com.juyu.miliao.api.dao.mysql;

import java.util.HashMap;
import java.util.Map;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.juyu.miliao.api.domain.Order;

@Repository
public class OrderDao {
	@Autowired
	private SqlSession sqlSession;
	
	public int insertOrder(Order order){
		return sqlSession.insert("insertOrder", order);
	}

	public int updateOrderById(String orderId, String outId){
		Map<String, Object> params = new HashMap<>();
		params.put("orderId", orderId);
		params.put("outId", outId);
		return sqlSession.update("updateOrderById", params);
	}

	public Order findOrderByOrderId(String orderId) {
		return sqlSession.selectOne("findOrderByOrderId",orderId);
	}

	public int findOrderByOutId(String outId) {
		return sqlSession.selectOne("findOrderByOutId",outId);
	}

}
